import { getHomeHotSuggests,getHomeCategories } from "@/services/modules/home";
import { defineStore } from "pinia";
import HYRequest from '../../services/request/index'
const useHomeStore=defineStore("home",{
    state:()=>({
        hotsuggests:[],
        categories:[],
        houselist:[],
    }),
    actions:{
        async fetchHotSuggests(){
            const res=await HYRequest.get({url:'/home/hotSuggests'});
            // console.log(res);           
            this.hotsuggests=res.data;
            // console.log(this.hotsuggests);
            
        },

        async fetchCategories(){
            const res=await HYRequest.get({url:'/home/categories'})
        
            this.categories=res.data;
        },
        async fetchHouselistData(currentpage){
            const res=await HYRequest.get(
                {url:'/home/houselist',
                 params:{
                    page:currentpage    // 请求更多数据时，page要改变。
                }
            })
            this.houselist.push(...res.data);

        }

        
    }
})

export default useHomeStore